import { request } from '@/utils/request';
import CRUD from '@/utils/request/CRUD';
export type ProcessDefinitionVO = {
  id: string
  version: number
  deploymentTIme: string
  suspensionState: number
  formType?: number
}

export type ModelVO = {
  id: number
  formName: string
  key: string
  name: string
  description: string
  category: string
  formType: number
  formId: number
  formCustomCreatePath: string
  formCustomViewPath: string
  processDefinition: ProcessDefinitionVO
  status: number
  remark: string
  createTime: string
  bpmnXml: string
}
// CRUD 操作
export const modelCRUD = CRUD('/bpm/model');

// 部署流程
export function deployModel(id: string) {
  return request.post({
    url: `/bpm/model/deploy?id=${id}`,
  });
}

// 获取流程模型
export function getModel(params: Record<string, any>) {
  return request.get({
    url: '/bpm/model/get',
    params,
  });
}

// 更新流程模型
export function updateModel(id: string, data: Record<string, any>) {
  return request.put({
    url: `/bpm/model/update?id=${id}`,
    data,
  });
}

// 更新流程模型的状态
export function updateModelState(data: Record<string, any>) {
  return request.put({
    url: '/bpm/model/update-state',
    data,
  });
}


export function updateModelBpmn(data: Record<string, any>) {
  return request.put({
    url: '/bpm/model/update-bpmn',
    data,
  });
}